import java.io.*;
public class MyCP {
    public static void main(String[] args) {
        String t = args[0];
        File root = new File(args[1]);   //源文件
        File goal = new File(args[2]);   //目标文件
        try {
            Reader shuru = new FileReader(root);
            BufferedReader input = new BufferedReader(shuru);
            String num = input.readLine();        //读取源文件中的字符串
            String result = "";
            if(t.equals("-tx")){             //将十进制转化为二进制
                result = Integer.toBinaryString(Integer.parseInt(num));
            }
            else{                            //将二进制转化成十进制
                result = Integer.valueOf(num,2).toString();
            }
            Writer output = new FileWriter(goal);      //将转化后的结果写入目标文件
            BufferedWriter bufferedWriter = new BufferedWriter(output);
            bufferedWriter.write(result);
            input.close();
            bufferedWriter.close();
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}
